<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{https://www.makeapie.cn/dep/echarts/map/js/china.js}"></script>
    <script th:src="@{https://oisanjavax.github.io/echarts-wordcloud/dist/echarts-wordcloud.min.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <script th:src="@{/layui/layui.js}"></script>
</head>
<body class="childrenBody">
<div >

    <div class="layui-bg-gray" style="padding: 30px;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="layui-panel">
<!--                    实时数据展示-->
                    <div style="margin-left: 100px;padding-top: 60px">
                        <div class="layui-carousel" id="test1" lay-filter="test1">
                            <div carousel-item="" style="width: 700px;height: 200px">
                                <div><img style="height: 100%;width: 100%" th:src="@{/images/banner3.jpg}"></div>
                                <div><img style="height: 100%;width: 100%" th:src="@{/images/banner2.jpg}"></div>
                                <div><img style="height: 100%;width: 100%" th:src="@{/images/banner1.jpg}"></div>
                            </div>
                        </div>
                    </div>
                    中国疫情饼图
                    <div id="main" style= "width: 700px;height:600px;"></div>
                </div>
            </div>
            <div class="layui-col-md4">
                <div style="padding-top: 10px">
                    <div class="layui-panel">
                        <div id="ciyun" style= "width:440px;height:300px;"></div>
                        <!--新闻数据-->
                        <div  style="padding-top: 10px">
                            <ul class="layui-timeline">
                                <li  th:each="n : ${newsList}" class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis"></i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title" th:text="${#dates.format(n.createTime,'yyyy-MM-dd HH:ss')}">8月18日</h3>
                                        <p>
                                            <br><span class="layui-badge layui-bg-orange">标题:</span><span th:text="${n.title}"></span>
                                            <br><span class="layui-badge layui-bg-green">内容:</span><span th:text="${n.content}"></span>
                                            <!--                                        <br><span class="layui-badge layui-bg-blue">图片:</span><span th:text="${n.pic}"></span>-->
                                            <br><img th:src="${n.pic}"style="height: 100px;width: 100px">
                                        </p>
                                    </div>
                                </li>
                            </ul>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script>
    //JS
    layui.use(['carousel','element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,carousel = layui.carousel
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });
        //轮播图
        //常规轮播
        carousel.render({
            elem: '#test1'
            ,arrow: 'always'
            ,height:'220px'
            ,width:'350px'
        });

    });
</script>
<script>
  var myChart = echarts.init(document.getElementById('main'));
  var dataList = []
  option = {
    title: {
      text: '中国各省疫情分布',
      subtext: '饼图',
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      left: 'left'
    }

  };
  $.ajax({
      dataType:"json",
      url:"/index/queryPie",
      success:function (data){
          for (let i in data){
              dataList[i] = data[i]
          }myChart.setOption({
              series: [
                  {
                      name: '中国各省疫情分布',
                      type: 'pie',
                      radius: '50%',
                      data: dataList,
                      emphasis: {
                          itemStyle: {
                              shadowBlur: 10,
                              shadowOffsetX: 0,
                              shadowColor: 'rgba(0, 0, 0, 0.5)'
                          }
                      }
                  }
              ]
          })
      }

  })
  myChart.setOption(option);
</script>
<script type="text/javascript">
    var Chart = echarts.init(document.getElementById('ciyun'));
    var hotlist = [];

    var wordcloud_car_color =["#60ACFC", "#61D7D3", "#AEE498", "#32D3EB", "#999999"];

    ciyunoption = {

        title:{
            show: true,
            text: "微博热搜",
            textStyle: {
                color: '#666666',
                fontSize: 14
            }
        },
        tooltip:{
            trigger: "item"
        },
        toolbox: {
            show: true,
            feature: {
                dataView: {
                    show: true
                },
                restore: {
                    show: true
                }
            }
        },
    };

    $.ajax({
        url: "/index/ciyun",
        dataType: "json",
        success:function (data){
            for (let i in data){
                hotlist[i] = data[i];
            }Chart.setOption({
                series: [ {
                    type: 'wordCloud',
                    sizeRange: [10, 80],
                    rotationRange: [-90, 90],
                    rotationStep: 90,
                    gridSize: 2,

                    // The shape of the "cloud" to draw. Can be any polar equation represented as a
                    // callback function, or a keyword present. Available presents are circle (default),
                    // cardioid (apple or heart shape curve, the most known polar equation), diamond (
                    // alias of square), triangle-forward, triangle, (alias of triangle-upright, pentagon, and star.
                    shape: 'square',

                    //maskImage: maskImage,
                    left: 'center',
                    top: 'center',
                    //width: '60%',
                    //height: '80%',
                    //right: null,
                    //bottom: null,
                    drawOutOfBound: false,
                    textStyle: {
                        normal: {
                            //color: '#60ACFC',
                            color: function () {
                                // 随机从颜色序列中取色
                                var index = Math.floor((Math.random()*wordcloud_car_color.length));
                                //console.log('index:'+index);
                                //console.log('colorOrder:'+colorOrder[index]);
                                return wordcloud_car_color[index];
                            }
                        },
                        emphasis: {
                            color: '#60ACFC',
                            shadowBlur: 6,
                            shadowColor: '#dddddd'
                        }
                    },
                    data: hotlist.sort(function (a, b) {
                        return b.value  - a.value;
                    })
                } ]
            })
        }
    })
    Chart.setOption(ciyunoption);
</script>
</body>
</html>